package influence.propagation.implementation;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import influence.propagation.core.NodeModel;
import influence.propagation.core.ResultSet;
import influence.propagation.core.ResultSetBuilder;

public class DepthResultSetBuilder implements ResultSetBuilder {
	
	private HashMap<Integer, List<NodeModel>> resultSet = new HashMap<Integer, List<NodeModel>>();
	private int state = 0;

	@Override
	public void put(NodeModel node, boolean isNewIteration) {
		resultSet.get(new Integer(state)).add(node);
	}

	@Override
	public ResultSet getIstance() {
		return new ConcreteResultSet(resultSet);
	}

	@Override
	public void putInitialActiveNode(NodeModel node) {
		Integer i = Integer.parseInt((String) node
				.getProperty(ActiveNodeProperties.NAME));
		resultSet.put(new Integer(i), new ArrayList<NodeModel>());
		state++;
	}
}
